import * as type from '../mutation-type'

const initState = {
  // 详情
  order: {
    id: null,
    display_id: null,
    status: null,
    category: null,
    step: [],
    customer: {},
    optometrist: {},
    address: {},
    report: {
      content: {
      }
    },
    order_items: [],
    coupon: {},
    delta_price: -40,
    express_number: null,
    invoice: null,
    comment_admin: null,
    comment_express: null,
    return_visit: null,
    aftermarket: {},
    recipe_type: null,
  },
  // 列表
  orders: {
    statistics: {
      archived: {},
      processing: {},
      waiting_for: {},
    },
    orders: [],
  },
}

const state = _.cloneDeep(initState)

const mutations = {
  // 列表
  [type.GET_ORDERS] (state, value, concat) {
    state.orders.statistics = value.statistics
    if (concat) {
      state.orders.orders.push(...value.orders)
    } else {
      state.orders.orders = value.orders
    }
  },

  // 详情
  [type.GET_ORDER] (state, value) {
    state.order = _.assign(value, {
      notify: false,
    })
  },

}

export default {
  state,
  mutations
}
